package org.finesys.system.service.impl;

import org.finesys.common.constants.CacheConstants;
import org.finesys.common.mp.core.service.impl.BaseServiceImpl;
import org.finesys.system.api.entity.SysOauthClientDetails;
import org.finesys.system.mapper.SysOauthClientDetailsMapper;
import org.finesys.system.service.SysOauthClientDetailsService;
import org.springframework.cache.annotation.CacheEvict;
import org.springframework.stereotype.Service;

import java.util.Arrays;

@Service
public class SysOauthClientDetailsServiceImpl extends BaseServiceImpl<SysOauthClientDetailsMapper, SysOauthClientDetails> implements SysOauthClientDetailsService {
    @Override
    @CacheEvict(value = CacheConstants.CLIENT_DETAILS_KEY, key = "#id")
    public Boolean removeClientDetailsByIds(Long[] ids) {
        return this.removeBatchByIds(Arrays.asList(ids));
    }

    @Override
    @CacheEvict(value = CacheConstants.CLIENT_DETAILS_KEY, key = "#sysOauthClientDetails.clientId")
    public Boolean updateClientDetailsById(SysOauthClientDetails sysOauthClientDetails) {
        return baseMapper.updateById(sysOauthClientDetails) > 0;
    }

    @Override
    @CacheEvict(value = CacheConstants.CLIENT_DETAILS_KEY, allEntries = true)
    public void sync() {

    }
}
